﻿CREATE PROCEDURE state_Loan_AssignGLProgram
	@LoanID int
AS

DECLARE @GLProgramID int,@GLProgramName varchar(128) 
SELECT 
@GLProgramID = dbo.GL_ProgramIDByState(StatusID),
@GLProgramName = dbo.GL_ProgramNameByState(StatusID) 
FROM t_Loan WHERE ID = @LoanID
IF @GLProgramID IS NULL AND @GLProgramName IS NULL RETURN

UPDATE t_Loan SET GLProgramID = @GLProgramID WHERE ID = @LoanID AND ISNULL(GLProgramID,0) <> ISNULL(@GLProgramID,0)
